<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="../../include/admincontent.jsp" %>
<div id="Content">
    <table class="treeTable inputform">
        <thead>
        <tr>
            <td align="center"><b>${tname}</b></td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>${msinfo}</td>
        </tr>
        </tbody>
    </table>
    <form id="Validform" method="post" action="/Do/MS/ScoreAction?msuid=${uid}&pid=${pid}">
        <table class="treeTable inputform" id="stable" style="margin-top:3px;">
            <thead>
            <tr>
                <td rowspan="2" width="120">评价要素</td>
                <td rowspan="2">观察要点</td>
                <td rowspan="2" width="60">分数</td>
                <td colspan="4">评分标准</td>
                <td rowspan="2" width="60">要素得分</td>
            </tr>
            <tr>
                <td width="60">好</td>
                <td width="60">较好</td>
                <td width="60">一般</td>
                <td width="60">差</td>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="_item" items="${items}" varStatus="item">
                <tr>
                    <td>${_item.name}<input type="hidden" name="eva[${item.index}].name" value="${_item.name}"/></td>
                    <td>${_item.remark}<input type="hidden" name="eva[${item.index}].remark" value="${_item.remark}"/>
                    </td>
                    <td>${_item.allpoint}分<input type="hidden" name="eva[${item.index}].allpoint"
                                                 value="${_item.allpoint}"/></td>
                    <td>${_item.level1}<input type="hidden" name="eva[${item.index}].level1" value="${_item.level1}"/>
                    </td>
                    <td>${_item.level2}<input type="hidden" name="eva[${item.index}].level2" value="${_item.level2}"/>
                    </td>
                    <td>${_item.level3}<input type="hidden" name="eva[${item.index}].level3" value="${_item.level3}"/>
                    </td>
                    <td>${_item.level4}<input type="hidden" name="eva[${item.index}].level4" value="${_item.level4}"/>
                    </td>
                    <c:choose>
                        <c:when test="${empty type}">
                            <td>
                                <div><input type="text" name="eva[${item.index}].point" value="${_item.point}"
                                            datatype="zzs" nullmsg="请评分完成后再提交"/></div>
                            </td>
                        </c:when>
                        <c:otherwise>
                            <td>
                                <div><input type="text" name="eva[${item.index}].point" value="${_item.allpoint}"
                                            datatype="zzs" nullmsg="请评分完成后再提交"/></div>
                            </td>
                        </c:otherwise>
                    </c:choose>
                </tr>
            </c:forEach>
            <tr>
                <td>初步评价：</td>
                <td colspan="7">
                    <div><textarea name="remark" rows="" cols="" datatype="*" nullmsg="请填写评价信息">${remark}</textarea>
                    </div>
                </td>
            </tr>
            <tr>
                <td>面试意见：</td>
                <td colspan="7">
                    <div class="radio1">
                        通过[<span>好(90分以上)</span>
                        <span>较好(80-89分)</span>
                        <span>一般(60-79分)]</span>
                        <span>不通过(59分及以下)</span>
                        <p id="allscore" style="width:100px;margin:0;float:right;color:red;">总分： 100 分</p>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="btnbar" style="margin-top:10px;text-align:right;">
            <button type="submit" class="save">提交评分结果</button>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        getAllScore();
        $('#stable input[type=text]').keyup(function () {
            if (isNaN($(this).val())) {
                $(this).val('');
            }
            getAllScore();
        });
    });

    function getAllScore() {
        var score = 0;
        $('#stable tbody tr').each(function (index) {
            var obj = $(this);
            if (obj.find('td:last input[type=text]').length > 0) {
                var bz = parseInt(obj.find('td:eq(2) input').val());
                var point = parseInt(obj.find('td:last input[type=text]').val());
                if (!isNaN(point)) {
                    if (point > bz || point < 0) {
                        point = 0;
                        obj.find('td:last input[type=text]').val('');
                    }
                    score += point;
                }
            }
        });
        $('#allscore').html('总分：' + score + '分');
        $('.radio1 span').removeClass('checked');
        if (score >= 90) {
            $('.radio1 span:first').addClass('checked');
        }
        if (score > 79 && score < 90) {
            $('.radio1 span:eq(1)').addClass('checked');
        }
        if (score > 59 && score < 80) {
            $('.radio1 span:eq(2)').addClass('checked');
        }
        if (score < 60) {
            $('.radio1 span:last').addClass('checked');
        }
    }

</script>
</body>
</html>